﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 增加岗位分配表 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SysHrJobAssignmentRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrJobAssignmentRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateTable(
                name: "SysHrJobAssignmentRequestBillEntry",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PersonId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StaffNo = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
                    JobPositionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    EntryRemark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
                    JobAssignmentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrJobAssignmentRequestBillEntry", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBillEntry_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBillEntry_SysHrJobAssignmentRequestBill_JobAssignmentId",
                        column: x => x.JobAssignmentId,
                        principalTable: "SysHrJobAssignmentRequestBill",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBillEntry_SysJobPosition_JobPositionId",
                        column: x => x.JobPositionId,
                        principalTable: "SysJobPosition",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBillEntry_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrJobAssignmentRequestBillEntry_SysPerson_PersonId",
                        column: x => x.PersonId,
                        principalTable: "SysPerson",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBill_GroupId",
                table: "SysHrJobAssignmentRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBill_OrgId",
                table: "SysHrJobAssignmentRequestBill",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBillEntry_GroupId",
                table: "SysHrJobAssignmentRequestBillEntry",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBillEntry_JobAssignmentId",
                table: "SysHrJobAssignmentRequestBillEntry",
                column: "JobAssignmentId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBillEntry_JobPositionId",
                table: "SysHrJobAssignmentRequestBillEntry",
                column: "JobPositionId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBillEntry_OrgId",
                table: "SysHrJobAssignmentRequestBillEntry",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrJobAssignmentRequestBillEntry_PersonId",
                table: "SysHrJobAssignmentRequestBillEntry",
                column: "PersonId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysHrJobAssignmentRequestBillEntry");

            migrationBuilder.DropTable(
                name: "SysHrJobAssignmentRequestBill");
        }
    }
}
